package com.edu360.utils

object AreaDistributionUtil {
  //根据逻辑计算原始请求，requestmode==1&&processnode>=1
    def selectPrimaryRequest(requestmode:Int,processnode:Int):Int={
      if (requestmode==1&&processnode>=1){
        1
      }else{
        0
      }
    }
  //根据逻辑计算有效请求，requestmode==1&&processnode>=2
  def selectValidRequest(requestmode:Int,processnode:Int):Int={
    if (requestmode==1&&processnode>=2){
      1
    }else{
      0
    }
  }
  //根据逻辑计算广告请求，requestmode==1&&processnode==3
  def selectAdvRequest(requestmode:Int,processnode:Int):Int={
    if (requestmode==1&&processnode==3){
      1
    }else{
      0
    }
  }
  //根据逻辑计算参与竞价的次数，iseffective==1&&isbilling==1&&isbid==1&&adorderid != 0
  def selectJoinBidding(iseffective:Int,isbilling:Int,isbid:Int,adorderid:Int):Int={
    if (iseffective==1&&isbilling==1&&isbid==1&&adorderid != 0){
      1
    }else{
      0
    }
  }
  //根据逻辑计算成功竞价的次数，iseffective==1&&isbilling==1&&iswin==1
  def selectSuccessBidding(iseffective:Int,isbilling:Int,iswin:Int):Int={
    if (iseffective==1&&isbilling==1&&iswin==1){
      1
    }else{
      0
    }
  }
  //根据逻辑针对广告主统计：广告在终端实际被展示的数量，requestmode==2&&iseffective==1
  def selectAdverShow(requestmode:Int,iseffective:Int):Int={
    if (requestmode==2&&iseffective==1){
      1
    }else{
      0
    }
  }
  //根据逻辑针对广告主统计：广告展示后被受众实际点击的数量，requestmode==3&&iseffective==1
  def selectAdverClick(requestmode:Int,iseffective:Int):Int={
    if (requestmode==3&&iseffective==1){
      1
    }else{
      0
    }
  }
  //根据逻辑计算DSP广告消费，iseffective==1&&isbilling==1&&iswin==1
  def selectDspConsume(iseffective:Int,isbilling:Int,iswin:Int,winprice:Double):Double={
    if (iseffective==1&&isbilling==1&&iswin==1){
      winprice/1000
    }else{
      0
    }
  }
  //根据逻辑计算DSP广告成本，iseffective==1&&isbilling==1&&iswin==1
  def selectDspCost(iseffective:Int,isbilling:Int,iswin:Int,adpayment:Double):Double={
    if (iseffective==1&&isbilling==1&&iswin==1){
      adpayment/1000
    }else{
      0
    }
  }
}
